//
//  PresentationShowAnimation.m
//  CKApp
//
//  Created by CC on 2020/9/4.
//  Copyright © 2020 This Moment. All rights reserved.
//

#import "PresentationShowAnimation.h"
#import "PresentationModalConfig.h"
#import "LcFoundation.h"

@implementation PresentationShowAnimation
- (NSTimeInterval)transitionDuration:(id<UIViewControllerContextTransitioning>)transitionContext {
  return PRESENTATION_ANIMATE_DURATION;
}

- (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext {
  UIViewController* toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
  UIView* toView = [transitionContext viewForKey:UITransitionContextToViewKey];
  if (toViewController && toView) {
    UIView* containerView = transitionContext.containerView;
    toView.frame = [transitionContext finalFrameForViewController:toViewController];
    [containerView addSubview:toView];
    toView.transform = CGAffineTransformMakeTranslation(0, LcUIUtility.screenHeight);
    [UIView animateWithDuration:PRESENTATION_ANIMATE_DURATION delay:PRESENTATION_DELAY options:UIViewAnimationOptionCurveEaseInOut animations:^{
      toView.transform = CGAffineTransformMakeTranslation(0, 0);
    } completion:^(BOOL finished) {
      [transitionContext completeTransition:finished];
    }];
  }
}

@end
